package agh.sr.lab4.chat.server;

import Chat.AccountAlreadyExistsException;
import Chat._ChatManagerDisp;
import Ice.Current;

public class ChatManagerI extends _ChatManagerDisp {

	private static final long serialVersionUID = -5334363392682000469L;
	private IChatDataProvider chatDataProvider;

	public ChatManagerI(IChatDataProvider chatDataProvider) {
		this.chatDataProvider = chatDataProvider;
	}

	@Override
	public synchronized void createAccount(String nick, Current __current)
			throws AccountAlreadyExistsException {

		if (chatDataProvider.doesAccountExists(nick))
			throw new AccountAlreadyExistsException();

		chatDataProvider.addNick(nick);
	}

}
